package com.woniu.airent.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.airent.dto.HouseDto;
import com.woniu.airent.entity.House;
import com.woniu.airent.service.impl.PublishHouseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("house")
public class PublishHouseController {
    @Autowired
    PublishHouseServiceImpl publishHouseServiceImpl;

    @RequestMapping("/publish")
    @ResponseBody
    public Map publishHouse(
                               String content,
                               @RequestParam(value = "pageNow",defaultValue = "1") Integer pageNow,
                               @RequestParam(value = "pageSize",defaultValue = "2") Integer pageSize){
        PageInfo<House> pageInfo = publishHouseServiceImpl.publishHouse(content,pageNow, pageSize);
        Map map=new HashMap();
        map.put("pageInfo",pageInfo);
        map.put("content",content);
        return map;
    }
    @RequestMapping("/updateHouse")
    @ResponseBody
    public HouseDto updateHouse(Integer hid){
        HouseDto houseDto=publishHouseServiceImpl.findHouseById(hid);
        return houseDto;


    }


}
